//
//  UIScrollView+Refresh.h
//  SHDoctor
//
//  Created by Mac mini on 15/10/10.
//  Copyright © 2015年 ShiHeng. All rights reserved.
//

#import <UIKit/UIKit.h>

@class UIScrollViewRefreshHeaderView;
@class UIScrollViewRefreshFooterView;

typedef NS_ENUM(NSUInteger, RefreshDirection) {
    RefreshDirectionIsReload = 0,           /**< 下拉刷新 */
    RefreshDirectionIsLoadMore = 1,         /**< 上拉加载更多*/
};

@protocol UIScrollViewRefreshDelegate <UIScrollViewDelegate>

@optional

- (BOOL)scrollViewWillRefreshWithDirection:(RefreshDirection)direction;
- (void)scrollViewDidRefreshWithDirection:(RefreshDirection)direction;

@end

@interface UIScrollView(Refresh)

@property (nonatomic, weak) id<UIScrollViewRefreshDelegate> refreshDelegate; /**< 建议在viewWillAppear里设置delegate， 在viewWillDisappear里取消delegate */


@property (nonatomic, assign) UIEdgeInsets settingInset;            /**< 设置的偏移值【默认为UIEdgeInsetsZero】*/

- (void)reloadRefreshData;

@property (nonatomic, strong) UIScrollViewRefreshHeaderView *headerView;
@property (nonatomic, strong) UIScrollViewRefreshFooterView *footerView;

@end



#pragma mark -
#pragma mark - UIScrollViewRefreshView methods

@interface UIScrollViewRefreshView : UIView 

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIActivityIndicatorView *loadingActivity;
@property (nonatomic, strong) UILabel *lastLoadingTime;

@property (nonatomic, readonly) BOOL isLoading;

+ (instancetype)createView;

- (void)startLoading;
- (void)stopLoading;

@end


@interface UIScrollViewRefreshHeaderView : UIScrollViewRefreshView


@end


@interface UIScrollViewRefreshFooterView : UIScrollViewRefreshView

@end